//
//  ZYCTeaLeaveRecordDetailFlowChartCell.m
//  ZDSC
//
//  Created by 张威 on 2021/11/2.
//

#import "ZYCTeaLeaveRecordDetailFlowChartCell.h"
#import "ZYCTeaLeaveHeaderView.h"
#import "ZYCTeaLeaveFlowChartModel.h"


@interface ZYCTeaLeaveRecordDetailFlowChartCell ()

@property (nonatomic, strong) ZYCTeaLeaveHeaderView *headerView;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UIView *line;
@end

@implementation ZYCTeaLeaveRecordDetailFlowChartCell

- (void)setModel:(ZYCTeaLeaveFlowChartModel *)model{
    _model = model;
    _headerView.titleLabel.text = model.applyUserName;
    _statusLabel.text = model.applyStatus;
    if ([model.applyStatus isEqualToString:@"驳回"]) {
        _statusLabel.textColor = HEX_RGB(@"#E93C06");
    }else  if ([model.applyStatus isEqualToString:@"撤销"]){
        _statusLabel.textColor = HEX_RGB(@"#999999");
    }else{
        _statusLabel.textColor = HEX_RGB(@"#41B166");
    }
    _detailLabel.text = model.applyOpnion;
    if (model.isShow) {
        _line.hidden = NO;
    }else{
        _line.hidden = YES;
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.headerView];
        [self.contentView addSubview:self.statusLabel];
        [self.contentView addSubview:self.detailLabel];
        [self.contentView addSubview:self.line];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(24.0f);
            make.width.mas_equalTo(2.0f);
            make.top.bottom.equalTo(self.contentView);
        }];
        
        [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.line.mas_right).offset(27.0f);
            make.size.mas_equalTo(CGSizeMake(70.0f, 70.0f));
            make.top.equalTo(self.contentView).offset(20.0f);
        }];
        
        [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView);
            make.left.equalTo(self.headerView.mas_right).offset(19.0f);
        }];
        
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.statusLabel.mas_bottom).offset(5.0f);
            make.left.equalTo(self.headerView.mas_right).offset(19.0f);
            make.right.equalTo(self).offset(-25.0f);
        }];
        
 
    }
    return self;
}

- (ZYCTeaLeaveHeaderView *)headerView {
    if (!_headerView) {
        _headerView = [[ZYCTeaLeaveHeaderView alloc] init];
    }
    return _headerView;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.font = kCustomFont(@"PingFangSC-Semibold", 13.0f);
        _statusLabel.textAlignment = NSTextAlignmentLeft;
        _statusLabel.textColor = HEX_RGB(@"41B166");
    }
    return _statusLabel;
}

- (UILabel *)detailLabel {
    if (!_detailLabel) {
        _detailLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
        _detailLabel.numberOfLines = 0;
    }
    return _detailLabel;
}

- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = HEX_RGB(@"#BFC7D0");
        _line.alpha = 0.36f;
    }
    return _line;
}
@end
